Questions
23 of 30
1How can you centre text vertically and horizontally inside a box?
2What is the use of the white-space property?
3How can you truncate text with an ellipsis (...) in CSS?
4How do you wrap or prevent wrapping of text in a container?
5How do you make text responsive across different screen sizes?
6How do you justify text using CSS?
7What does text-shadow do? Give an example.
8How can you apply multiple shadows to text?
9How do you apply gradients to text in CSS?
10How do you control text overflow in a fixed-width container?
11What is the difference between em, rem, and px when styling text?
12How does font-weight differ from <b> tag in semantic meaning?
13How does accessibility relate to text formatting in HTML?
14What’s the difference between semantic and non-semantic text formatting tags?
15How can you ensure consistent text appearance across different browsers?
16What is the difference between font-style, font-variant, and font-weight?
17What is the role of @font-face in web typography?
18How can you import custom fonts in CSS?
19What’s the impact of using web fonts on performance?
20How can you optimise text rendering for readability?
21How do you make text appear vertically (top-to-bottom) using CSS?
22How do you style only the first letter or first line of a paragraph?
23How do you create a drop cap effect?
24How can you highlight a selected text range dynamically?
25How do you make text glow or have a neon effect using CSS?
26What CSS properties can you use for text animations?
27How can you apply a gradient background only to the text and not the entire element?
28How can you apply different styles to different words in the same line?
29How do you prevent text selection on a webpage?
30How do you implement responsive typography (fluid text size)?
23 / 30

How do you create a drop cap effect?

Creating a Drop Cap Effect with CSS

A drop cap is a large initial letter at the beginning of a paragraph that spans multiple lines, commonly used in print and digital typography to draw attention to the opening text.

Steps to Create a Drop Cap
  1. 1

    Use the ::first-letter pseudo-element to target the first character of the paragraph.

  2. 2

    Increase the font-size to make the initial letter larger than the body text.

  3. 3

    Use float: left; to allow the text to wrap around the drop cap.

  4. 4

    Add line-height and margin adjustments to align the drop cap with the surrounding text.

Example: Simple Drop Cap

In this example, the first letter of the paragraph becomes a prominent drop cap. The text wraps naturally around it, creating a visually appealing typographic effect.

Best Practices
  1. 1

    Ensure the drop cap size does not disrupt readability of the paragraph.

  2. 2

    Use contrast and color to make the drop cap stand out without being distracting.

  3. 3

    Test across different screen sizes to maintain proper alignment.

  4. 4

    Combine with line-height and margin for smooth integration with surrounding text.

  5. 5

    Use semantic HTML for the paragraph; avoid extra markup for the drop cap to keep the code clean.

Difficulty: 3/10
Topics: ::first-letter pseudo-element, float layout, responsive design

Scenario Questions

0-2 years experience
  1. 1

    How would you implement a drop cap for the first paragraph of an article using only CSS?

  2. 2

    If you needed the drop cap to work on both desktop and mobile, what CSS would you write?

  3. 3

    What happens if you forget to clear the float after the drop cap?

2-5 years experience
  1. 1

    You added a drop cap using ::first-letter and float, but the surrounding text sometimes overlaps on certain browsers. How would you debug and fix it?

  2. 2

    Explain the trade‑offs between using float versus CSS Grid/shape-outside for a drop cap in a responsive layout.

  3. 3

    If the design changes to have a multi‑line drop cap, how would you adjust your CSS?

5-8 years experience
  1. 1

    When building a reusable article component library, how would you design the drop‑cap styling to be themeable and avoid layout shifts across different content lengths?

  2. 2

    Discuss performance considerations of using pseudo‑elements for drop caps on pages with thousands of articles.

  3. 3

    How would you ensure the drop cap works correctly with right‑to‑left languages and accessibility tools?

8+ years experience
  1. 1

    Your company is migrating a legacy CMS to a new component‑based front‑end. How would you plan the migration of existing drop‑cap implementations to a unified design system while minimizing regression?

  2. 2

    What architectural decisions would you make to allow product teams to customize drop‑cap styles without breaking the core layout?

  3. 3

    How would you handle cross‑team coordination for supporting drop caps in both web and native (e.g., React Native) platforms?

Follow-up Questions

  • What CSS properties control the spacing around the drop cap?
  • How would you make the drop cap work with dynamic content length?
  • Can you describe any accessibility concerns with this technique?